home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / tasksel / tests / desktop < prev    next >
Encoding:
Text File  |  2007-03-14  |  2.1 KB  |  106 lines

  1. #!/bin/sh
  2. # Try to guess at whether the user would like a desktop installed on their
  3. # system. Of course Debian has many users who use it on a wide array of
  4. # hardware, so this is tricky, but it's only a default.
  5. set -e
  6.  
  7. if ! [ "$NEW_INSTALL" ]; then
  8.     exit 3
  9. fi
  10.  
  11. arch="$(dpkg --print-architecture)"
  12.  
  13. unmark () {
  14.     exit 3
  15. }
  16. mark () {
  17.     exit 2
  18. }
  19.  
  20. # A few arches have the lion's share of desktops.
  21. common_desktop_architecture () {
  22.     case "$arch" in
  23.     i386|amd64|powerpc*)
  24.         return 0
  25.     ;;
  26.     *)
  27.         return 1
  28.     ;;
  29.     esac
  30. }
  31.  
  32. # On some arches it's almost unheard of to run a desktop, at least using
  33. # this task.
  34. unlikely_desktop_architecture () {
  35.     case "$arch" in
  36.     m68k|s390|hppa)
  37.         return 0
  38.     ;;
  39.     *)
  40.         return 1
  41.     ;;
  42.     esac
  43. }
  44.  
  45. # Modern desktops take a lot of ram.
  46. enough_ram () {
  47.     min_ram=64
  48.     ram=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }) || true # kb
  49.     # The 4 is a fuzz factor to allow for kernel ram usage.
  50.     if [ "$ram" ] && [ "$ram" -ge "$(expr $(expr $min_ram - 4) \* 1024)" ]; then
  51.         return 0
  52.     else
  53.         return 1
  54.     fi
  55. }
  56.  
  57. # The desktop task requires 2 gb or so of disk in /usr. 
  58. # FIXME: this should really be generalised and used for tasksel to not
  59. # suggest any task for which there is not enough disk.
  60. enough_disk () {
  61.     min_disk=2
  62.     disk=$(df -P /usr | tail -1 | awk '{print $4}')
  63.     if [ "$disk" ] && [ "$disk" -ge "$(expr $min_disk \* 1024 \* 1024)" ]; then
  64.         return 0
  65.     else
  66.         return 1
  67.     fi
  68. }
  69.  
  70. desktop_hardware () {
  71.     if laptop-detect; then
  72.         # Nearly always appropriate to include a desktop.
  73.         return 0
  74.     else
  75.         # TODO: test for the existence of a framebuffer and a mouse.
  76.         # A mouse, in particular, almost always indicates a
  77.         # desktop.
  78.         :
  79.     fi
  80.     return 1
  81. }
  82.  
  83. if ! enough_ram || ! enough_disk; then
  84.     unmark
  85. fi
  86.  
  87. if desktop_hardware; then
  88.     mark
  89. fi
  90.  
  91. if unlikely_desktop_architecture; then
  92.     unmark
  93. elif common_desktop_architecture; then
  94.     # XXX further heuristics here to avoid selecting the task on
  95.     # high-end hardware that's intended to be used as a server.
  96.     # For example, if it has two NICs with link, it's probably a
  97.     # server. If it's rackmountable, a server, etc.
  98.  
  99.     mark # probably a desktop ...
  100. else
  101.     # XXX further heuristics here
  102.     :
  103. fi
  104.  
  105. unmark
  106.